package com.shared_file_bucket.service;


import com.shared_file_bucket.common.domain.R;
import com.shared_file_bucket.common.domain.TreeNode;
import com.shared_file_bucket.model.FileAddDTO;
import com.shared_file_bucket.model.FileVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

/**
 * 文件管理接口
 *
 * @author zhangrui.i
 * @date 2021/3/15
 */
public interface LocalFileService {

    /**
     * 获取站点目录树
     *
     * @param dir
     * @return
     */
    List<TreeNode<String>> getSiteDirectoryTreeData(String root, String dir);

    /**
     * 获取指定目录下的文件
     *
     * @param dirPath
     * @param filterFilename
     * @return
     */
    R<List<FileVO>> getSiteFileList(String root, String dirPath, String filterFilename);

    /**
     * 新建文件
     *
     * @param dto
     * @return
     * @throws IOException
     */
    void addFile(String root, FileAddDTO dto) throws IOException;

    /**
     * 删除文件
     *
     * @param filePathArr
     * @return
     * @throws IOException
     */
    void deleteFiles(String root, String[] filePathArr) throws IOException;

    /**
     * 上传文件到站点指定目录
     *
     * @param dir
     * @param file
     * @throws IOException
     */
    void uploadFile(String root, String dir, MultipartFile file) throws IOException;

    void renameFile(String root, String filePath, String rename) throws IOException;

    String getRootByUserId();

    String getRootByShareCode(String ShareCode);

    void packageDirAndDownload(HttpServletRequest request, HttpServletResponse response, String root) throws IOException;
}
